home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1996 January / macformat-033.iso / mac / Shareware City / Applications / State-Smart ƒ / Scripts / ßScripts / stack.txt < prev   
Encoding:
Text File  |  1995-10-24  |  21.5 KB  |  884 lines

  1. -- stack: in
  2. -- format: 10 (HyperCard 2)
  3. -- flags: 0x1000 (none)
  4. -- protect password hash: 0
  5. -- maximum user level: 5 (scripting)
  6. -- window: Rect(x1=64, y1=69, x2=576, y2=411)
  7. -- screen: Rect(x1=0, y1=0, x2=640, y2=480)
  8. -- card dimensions: w=512 h=342
  9. -- scroll: x=0 y=0
  10. -- background count: 1
  11. -- first background id: 2710
  12. -- card count: 1
  13. -- first card id: 3040
  14. -- list block id: 3975
  15. -- print block id: 0
  16. -- font table block id: 3517
  17. -- style table block id: 3275
  18. -- free block count: 2
  19. -- free size: 7424 bytes
  20. -- total size: 32768 bytes
  21. -- stack block size: 19968 bytes
  22. -- created by hypercard version: 0x02006043
  23. -- compacted by hypercard version: 0x02008000
  24. -- modified by hypercard version: 0x02008000
  25. -- opened by hypercard version: 0x02308000
  26. -- patterns[0]: 0x0000000000000000
  27. -- patterns[1]: 0x8000000008000000
  28. -- patterns[2]: 0x8800220088002200
  29. -- patterns[3]: 0x8888222288882222
  30. -- patterns[4]: 0x88AA22AA88AA22AA
  31. -- patterns[5]: 0xCCAA33AACCAA33AA
  32. -- patterns[6]: 0xEEAABBAAEEAABBAA
  33. -- patterns[7]: 0xEEBBBBEEEEBBBBEE
  34. -- patterns[8]: 0xFFBBFFEEFFBBFFEE
  35. -- patterns[9]: 0xFFBBFFFFFFBBFFFF
  36. -- patterns[10]: 0x8010022001084004
  37. -- patterns[11]: 0xFFFFFFFFFFFFFFFF
  38. -- patterns[12]: 0x8822882288228822
  39. -- patterns[13]: 0x1122448811224488
  40. -- patterns[14]: 0xC4800C6843023026
  41. -- patterns[15]: 0xB130031BD8C00C8D
  42. -- patterns[16]: 0xAA00AA00AA00AA00
  43. -- patterns[17]: 0x8822552288225522
  44. -- patterns[18]: 0x8855225588552255
  45. -- patterns[19]: 0x77DD77DD77DD77DD
  46. -- patterns[20]: 0x8000000000000000
  47. -- patterns[21]: 0xAA55AA55AA55AA55
  48. -- patterns[22]: 0x038448300C020101
  49. -- patterns[23]: 0x8244394482010101
  50. -- patterns[24]: 0x8814224188412214
  51. -- patterns[25]: 0x8080413E080814E3
  52. -- patterns[26]: 0x22048C7422179810
  53. -- patterns[27]: 0xBE808808EB088880
  54. -- patterns[28]: 0x25C8328964244C92
  55. -- patterns[29]: 0xA29C41BE2AC914EB
  56. -- patterns[30]: 0x40A00000040A0000
  57. -- patterns[31]: 0x8040200002040800
  58. -- patterns[32]: 0xAA00800088008000
  59. -- patterns[33]: 0xFF80808080808080
  60. -- patterns[34]: 0x081C22C180010204
  61. -- patterns[35]: 0xFF808080FF080808
  62. -- patterns[36]: 0xF87422478F172271
  63. -- patterns[37]: 0xBF00BFBFB0B0B0B0
  64. -- patterns[38]: 0xFF7FBE5DA2418000
  65. -- patterns[39]: 0xFAF5FAF5A050A050
  66. -- checksum: 0xDE01303A
  67. ----- HyperTalk script -----
  68. --Intellimation suggested routines ---
  69. on unLockIt
  70.   set the userlevel to 5
  71.   show message
  72.   show tool window at 40,20
  73. end unLockIt
  74.  
  75. on LockIt
  76.   global UL
  77.   set the userlevel to UL
  78.   hide message
  79.   hide tool window
  80. end LockIt
  81.  
  82. on uf --unlock fields
  83.   TogFields unlock
  84. end uf
  85.  
  86. on lf --lock fields
  87.   TogFields lock
  88. end lf
  89.  
  90. on TogFields arg
  91.   if arg is "lock" then put true into tog else put false into tog
  92.   put the number of bg flds into nbgf
  93.   put the number of cd flds into ncdf
  94.   repeat with i = 1 to nbgf
  95.     set the lockText of bg fld i to tog
  96.   end repeat
  97.   repeat with i = 1 to ncdf
  98.     set the lockText of cd fld i to tog
  99.   end repeat
  100. end TogFields
  101.  
  102.  
  103.  
  104. on doWindows
  105.   put the number of lines of the windows into n
  106.   repeat with i = 1 to n
  107.     put line i of the windows
  108.     wait until the mouseclick
  109.   end repeat
  110. end doWindows
  111.  
  112. on resumeStack
  113.   global isinit
  114.   if not(isinit is true) then initSS
  115.   pass resumeStack
  116. end resumeStack
  117.  
  118.  
  119.  
  120. on initSS
  121.  
  122.   --check the version
  123.   if the version <2.0 then
  124.     answer "this stack requires HyperCard version 2.0 or above" with "Continue" or "Go Home"
  125.     if it is "Go Home" then go Home
  126.   end if
  127.   global isinit
  128.   global ul,USRLVL
  129.   if not (isinit is true) then
  130.     --save the current userlevel
  131.     put the userlevel into ul
  132.     --initialize system globals
  133.     lock screen
  134.     push cd
  135.     set the lockmessages to true
  136.     go "¬ßControl"
  137.     put cd fld "globlist" of cd "help" into gl
  138.     put the number of lines of gl into n
  139.     get cd fld "memory" of cd "help"
  140.     repeat with i = 1 to n
  141.       put line i of gl into vr
  142.       put "global " & vr into lin
  143.       do lin
  144.       put "put line " & i & " of it into " & vr into lin
  145.       do lin
  146.     end repeat
  147.  
  148.     --these globals aren't stored because the user can't change them
  149.     global NUMREG, NUMCAT, NONO, NAMENO, SWNO, SONGNO, ATCNO, IDNO, NUMOPT
  150.     put 6 into NUMREG
  151.     put 13 into NUMCAT
  152.     put 8 into NUMOPT
  153.     put the number of cd btn "NO" of cd "US home" into NONO
  154.     put the number of cd btn "SW" of cd "US home" into SWNO
  155.     put the number of cd btn "NAME" of cd "US home" into NAMENO
  156.     put the number of cd btn "SONG" of cd "US home" into SONGNO
  157.     put the number of cd btn "ATC" of cd "US home" into ATCNO
  158.     put the number of cd btn "Score Data" of cd "US home" into IDNO
  159.     pop cd
  160.     set the lockmessages to false
  161.   end if
  162.  
  163.  
  164.  
  165.   --put OUR credits in the Apple menu
  166.   put "About State-Smart..." into menuItem 1 of menu 1
  167.   set the menuMsg of menuItem 1 of menu 1 to "About"
  168.  
  169.  
  170.   --use the saved State-Smart user level
  171.   if USRLVL <> ""then  set the userLevel to USRLVL
  172.  
  173.   --create the State-Smart menu
  174.   if "State-Smart" is not in the menus then
  175.     create menu "State-Smart"
  176.     put "Print Map" & RETURN & "Export Map"& RETURN & "New Map" & RETURN & "-" & RETURN & "Quiz" & RETURN & "Sound" & RETURN & "Quiz Options" & RETURN & "Locate"& RETURN & "Locate Next"& RETURN & "Graph Data" & RETURN & "Palette" & RETURN & "New Password" & RETURN & "DeCrypt" into menu "State-Smart"
  177.     enable menu "State-Smart"
  178.  
  179.     --now make the menu do what we want it to
  180.     global snd
  181.     if snd <> "" then set the checkMark of menuItem "Sound" of menu "State-Smart" to snd
  182.     disable menuItem "New Map" of menu "State-Smart"
  183.     put the number of menuItems of menu "State-Smart" into nit
  184.     set the lockmessages to true
  185.     push cd
  186.     go "¬ßControl"
  187.     put cd fld "mumsgs" of first cd into temp
  188.     pop cd
  189.     set the lockmessages to false
  190.     repeat with i = 1 to nit
  191.       set the menuMsg of menuItem i of menu "State-Smart" to line i of temp
  192.     end repeat
  193.     set the cmdChar of menuItem "Locate" of menu "State-Smart" to L
  194.     set the cmdChar of menuItem "Locate Next" of menu "State-Smart" to G
  195.   end if
  196.   global isinit
  197.   put true into isinit  --we are initting now
  198.   unlock screen
  199. end initSS
  200.  
  201.  
  202.  
  203. on saveSS
  204.   lock screen
  205.   push cd
  206.   set the lockmessages to true
  207.   go "¬ßControl"
  208.   set the lockmessages to false
  209.   put cd fld "globlist" of cd "help"  into gl
  210.   put the number of lines of gl into n
  211.   repeat with i = 1 to n
  212.     put line i of gl into vr
  213.     put "global " & vr into lin
  214.     do lin
  215.     put "put "& vr & " into line " & i & " of temp" into lin
  216.     do lin
  217.   end repeat
  218.   put temp into card field "memory" of card "help"
  219.   pop cd
  220.   unlock screen
  221. end saveSS
  222.  
  223.  
  224.  
  225. on doMenu x
  226.   if (x is "Open Stack...") or  (x is "Go Home") or (x is "Close Stack") or (x is "New Stack...") or (x is "Quit HyperCard") then
  227.     --because we don't want to do a complete reinit each time
  228.     -- if "State-Smart" is in the menus then delete menu "State-Smart"
  229.     --  if "Map Color" is in the menus then delete menu "Map Color"
  230.     --  put "About HyperCard..." into menuItem 1 of menu 1
  231.     --set the menuMsg of menuItem 1 of menu 1 to empty
  232.     reset menubar
  233.     saveSS --this is why we include Quit HyperCard
  234.     global isinit
  235.     put false into isinit
  236.   end if
  237.   pass doMenu
  238. end doMenu
  239.  
  240. on About
  241.   visual dissolve slow to cd
  242.   go cd "About¬ß" of stack "¬ßControl"
  243. end About
  244.  
  245. function stkn c
  246. if c is "C" then return( "¬ßCities")
  247. else if c is "T" then return("¬ßTopography" )
  248. else if c is "X" then return("¬ßContours")
  249. else if c is "A" then return("¬ßCities")
  250. else return( "¬ßControl")
  251. end stkn
  252.  
  253. on doGraph
  254.   go first card of bg "Map Color BG" of stack "¬ßControl"
  255.   --nav --gets the general navigation palette up
  256. end doGraph
  257.  
  258. on doPal
  259.   --gets the appropriate palette window for current stack
  260.   --in case it has been inadvertently closed
  261.   put the short name of this stack into tsn
  262.   if tsn is "¬ßTopography" then put "TopNav" into tpn
  263.   if tsn is "¬ßContours" then put "ContPal" into tpn
  264.   if tsn is "¬ßCities" then put "CitPal" into tpn
  265.   if tsn is "¬ßControl" then put "SSNav" into tpn
  266.   if tsn is "¬ßUser Guide" then put "Navigator" into tpn
  267.   get the short name of this bg
  268.   if it is "Map Color BG" then put "Navigator" into tpn
  269.   if it contains "Region" then
  270.     dispPal "Compass"
  271.   end if
  272.   dispPal tpn
  273. end doPal
  274.  
  275. on dispPal pal
  276.   put findxy(pal) into xy
  277.   lock screen
  278.   if pal is not in the windows then
  279.     palette pal
  280.   end if
  281.   unlock screen
  282.   if xy is not empty then
  283.     show window pal at xy
  284.   else
  285.     show window pal
  286.   end if
  287. end dispPal
  288.  
  289.  
  290. function findxy pal
  291. --this is a workaround for a 2.0 bug where the
  292. --value of a multi item object only evaluates
  293. --to the first item.  I would have much preferred
  294. --to do this inline and use value but it doesn't work
  295. put "global "&pal&"Global" into line
  296. do line
  297. put "if "&pal&"Global is empty then put ""E&"0,0""E&" into ans" into line
  298. do line   --empty if never used before
  299. put "if "&pal&"Global is not empty then put "&pal&"Global into ans" into line
  300. do line   --otherwise use old value
  301. put "if "&pal&"Global is true then put ""E"E&" into ans" into line
  302. do line   --true if already showing no need to redo
  303. return ans
  304. end findxy
  305.  
  306.  
  307.  
  308. on protect
  309.   put the number of cds into n
  310.   repeat with i = 1 to n
  311.     set the cantDelete of cd i to TRUE
  312.   end repeat
  313. end protect
  314.  
  315. --handler for OFF-MAP buttons
  316. on mouseDown
  317.   put char 2 to 3 of word 3 of the target into s
  318.   if s is "OM" then
  319.     push cd
  320.     go cd "ad"
  321.   end if
  322. end mouseDown
  323.  
  324. --handler for adjacent state buttons
  325. --these buttons have no scripts so they fall through to here
  326. on mouseUp
  327.   put getEffect () into visef  --bases this on the clickloc
  328.   put char 2 to 3 of word 3 of the target into xn
  329.   if xn is "OM" then
  330.     pop card
  331.     exit mouseUp
  332.   end if
  333.   get the short name of this cd
  334.   if char 1 of it is "A" then put "C" into char 1 of it
  335.   put char 1 to 2 of it & xn into xn
  336.   visual visef
  337.   go card xn
  338. end mouseUp
  339.  
  340. function getEffect  --for adjacent state buttons
  341. put the clickV into cV
  342. put the clickH into cH
  343. put abs(cH - 256) into epsH
  344. put abs(cV - 171) into epsV
  345. if 1.5 * epsV ‚â• epsH then
  346.   if cV ‚â§ 171 then
  347.     put "Down" into direc
  348.   else
  349.     put "Up" into direc
  350.   end if
  351. else
  352.   if cH ‚â§ 256 then
  353.     put "Right" into direc
  354.   else
  355.     put "Left" into direc
  356.   end if
  357. end if
  358. return "scroll" && direc && "slow"
  359. end getEffect
  360.  
  361.  
  362. on doSound
  363.   set the checkMark of menuItem "Sound" of menu "State-Smart" to not (the checkMark of menuItem "Sound" of menu "State-Smart")
  364.   global snd
  365.   put not(snd) into snd
  366. end doSound
  367.  
  368.  
  369. on doKillQ
  370.   global QINP
  371.   answer "Abandon Quiz?" with "OK" or "Cancel"
  372.   if it is "OK" then
  373.     put false into QINP
  374.     put empty into QinpCard
  375.     cleanUp
  376.   end if
  377. end doKillQ
  378.  
  379. on cleanUp
  380.   global fname
  381.   if the short name of this bg is not "Info" then
  382.     cleanUSHome
  383.     --it must be the USA so make sure all the map stuff is showing
  384.   else
  385.     lock screen
  386.     hide bg field "Quiz field"
  387.     hide bg btn "Abort"
  388.     repeat with i = 1 to 4
  389.       put "Answer"&i into bn
  390.       put "Question"&i into fn
  391.       hide field fn
  392.       hide bg button bn
  393.     end repeat
  394.     if fname is not empty then show bg field fname
  395.     show window "SSNav"
  396.     unlock screen
  397.   end if
  398. end cleanUp
  399.  
  400.  
  401. on doPrint
  402.   doMenu "Print Card"
  403. end doPrint
  404.  
  405. on doExport
  406.   --put "¬ß" & the short name of this card into nn
  407.   set the userlevel to 4
  408.   --export paint to file nn
  409.   --answer "Exported paint file "&nn with "OK"
  410.   choose the pencil tool
  411.   doMenu "Export Paint..."
  412.   popUL
  413.   choose the browse tool
  414. end doExport
  415.  
  416. on goInfo
  417.   put the short name of this card into nme
  418.   put the name of this bg into tb
  419.   if tb contains "Region" then
  420.     beep
  421.     exit goInfo
  422.   else
  423.     put "I-" & char 3 to 4 of nme into nme
  424.     visual venetian blinds
  425.     go card nme of stack "¬ßControl"
  426.   end if
  427. end goInfo
  428.  
  429. on goCont
  430.   put the short name of this card into nme
  431.   put "X-" & char 3 to 4 of nme into nme
  432.   visual venetian blinds
  433.   if there is a stack "¬ßContours" then
  434.     go card nme of stack "¬ßContours"
  435.   else
  436.     answer "The Contours Data is available in the Registered Version."
  437.   end if
  438. end goCont
  439.  
  440. on goCit
  441.   put the short name of this card into nme
  442.   put "C-" & char 3 to 4 of nme into nme
  443.   visual venetian blinds
  444.   if there is a stack "¬ßCities" then
  445.     go card nme of stack "¬ßCities"
  446.   else
  447.     answer "The Cities Data is available in the Registered Version."
  448.   end if
  449. end goCit
  450.  
  451. on goReg
  452.   --this is different in control stack, so it has its own
  453.   get bg fld "Region"
  454.   put the short name of this card into sn
  455.   put (char 1 to 2 of sn) & it into crd
  456.   visual iris close slow
  457.   go cd crd
  458. end goReg
  459.  
  460. on goUSA
  461.   if the short name of this bg contains "Region" then
  462.     put the short name of this cd into tcn
  463.     put prefix(tcn) & "US" into zo
  464.     visual iris close slow
  465.     go cd zo
  466.   else
  467.     go card "US home"of stack "¬ßControl"
  468.   end if
  469. end goUSA
  470.  
  471. on goComp n   --compass handler
  472.   put item n of bg fld "Compdirs" into place
  473.   if place is not empty then
  474.     go cd place
  475.   else
  476.     beep
  477.   end if
  478. end goComp
  479.  
  480. on goTop
  481.   put the short name of this card into nme
  482.   put "T-" & char 3 to 4 of nme into nme
  483.   visual venetian blinds
  484.   if there is a stack "¬ßTopography" then
  485.     go card nme of stack "¬ßTopography"
  486.   else
  487.     answer "The Topographical Data is available in the Registered Version."
  488.   end if
  489. end goTop
  490.  
  491. on doLocate -- locates an item if possible
  492.   global placename
  493.   global maplist
  494.   ask "Place name?" with placename
  495.   if the result is "Cancel" then exit doLocate
  496.   put it into placename
  497.   lock screen
  498.   set the cursor to busy
  499.   put binsearch(placename) into answer
  500.   if answer is empty then
  501.     --do a general find
  502.     find chars placename
  503.     unlock screen
  504.     --answer "Not Found" with "OK"
  505.     exit doLocate
  506.   end if
  507.   unlock screen
  508.   put item 1 of answer into crd
  509.   put item 2 of answer into stk
  510.   put item 3 of answer into x
  511.   put item 4 of answer into y
  512.   if there is a stack stk then
  513.     go cd crd of stack stk
  514.     if the result is not empty then
  515.       answer "Card "&crd&" is missing." with "What?" or "I know"
  516.       exit doLocate
  517.     end if
  518.     set the cursor to hand
  519.     marker x,y
  520.   end if
  521. end doLocate
  522.  
  523.  
  524. function binsearch place
  525. --finds place in sorted list by alpha
  526. global maplist,mp,coordlist
  527. lock screen
  528. push cd
  529. go bg "index" of stack "¬ßControl"
  530. find string place in fld "dex"
  531. if the foundline is empty then
  532.   beep
  533.   pop cd
  534.   unlock screen
  535.   exit binsearch
  536. else
  537.   put word 2 of the foundline into lno
  538.   put item 2 of line lno of fld "dex" into maplist
  539.   put item 3 of line lno of fld "dex" into coordlist
  540.   put 2 into mp
  541.   put word 1 of maplist into crd
  542.   pop cd
  543.   unlock screen
  544. end if
  545. put word 1 of coordlist into x
  546. put word 2 of coordlist into y
  547. put char 1 of crd into c
  548. put stkn(c) into stk
  549. return( crd&","&stk&","&x&","&y)
  550. end binsearch
  551.  
  552.  
  553.  
  554. on doFNext  --finds the next location of placeName
  555.   global placeName,maplist,mp,coordlist
  556.   set the cursor to busy
  557.   if placename is empty then
  558.     beep
  559.     exit doFNext
  560.   end if
  561.   if maplist is empty then
  562.     beep
  563.     exit doFNext
  564.   end if
  565.   put the number of words of maplist into n
  566.   if mp>n then
  567.     beep
  568.     exit doFNext
  569.   end if
  570.   put word mp of maplist into crd
  571.   put char 1 of crd into c
  572.   put stkn(c) into stk
  573.   if there is a stack stk then
  574.     go cd crd of stack stk
  575.     put word 2*mp-1 of coordlist into x
  576.     put word 2*mp of coordlist into y
  577.     add 1 to mp
  578.     set the cursor to hand
  579.     marker x,y
  580.   end if
  581. end doFNext
  582.  
  583. on marker x,y
  584.   set the userlevel to 5
  585.   lock screen
  586.   doMenu "New Button"
  587.   set the name of btn "New Button" to "flash"
  588.   set the rect of btn "flash" to 0,0,15,15
  589.   set the style of btn "flash" to transparent
  590.   set the showname of btn "flash" to false
  591.   set the autohilite of btn "flash" to false
  592.   set the icon of btn "flash" to 1018
  593.   choose browse tool
  594.   popUL
  595.   show cd btn "flash" at x,y
  596.   unlock screen
  597.   set the lockmessages to true
  598.   repeat until the mouseclick
  599.     set the hilite of btn "flash" to not the hilite of btn "flash"
  600.     wait 10
  601.   end repeat
  602.   set the lockmessages to false
  603.   lock screen
  604.   set the userlevel to 5
  605.   choose button tool
  606.   select btn "flash"
  607.   domenu "Cut Button"
  608.   choose browse tool
  609.   popUL
  610. end marker
  611.  
  612.  
  613.  
  614.  
  615. ---------
  616.  
  617. --handler for adjacent state buttons
  618. --these buttons have no scripts so they fall through to here
  619. on mouseUp
  620.   put getEffect () into visef  --bases this on the clickloc
  621.   put char 2 to 3 of word 3 of the target into xn
  622.   if xn is "OM" then
  623.     pop cd
  624.     exit mouseUp
  625.   end if
  626.   get the short name of this cd
  627.   put char 1 to 2 of it & xn into xn
  628.   visual visef
  629.   go cd xname
  630. end mouseUp
  631.  
  632.  
  633. function getEffect  --for adjacent state buttons
  634. put the clickV into cV
  635. put the clickH into cH
  636. put abs(cH - 256) into epsH
  637. put abs(cV - 171) into epsV
  638. if epsV ‚â• epsH then
  639.   if cV ‚â§ 171 then
  640.     put "Down" into dir
  641.   else
  642.     put "Up" into dir
  643.   end if
  644. else
  645.   if cH ‚â§ 256 then
  646.     put "Right" into dir
  647.   else
  648.     put "Left" into dir
  649.   end if
  650. end if
  651. return "scroll" && dir && "slow"
  652. end getEffect
  653.  
  654.  
  655. --handler for OFF-MAP buttons
  656. on mouseDown
  657.   put char 2 to 3 of word 3 of the target into s
  658.   if s is "OM" then
  659.     push cd
  660.     go cd "ad"
  661.   end if
  662. end mouseDown
  663.  
  664. function prefix str
  665. return char 1 to 2 of str
  666. end prefix
  667.  
  668. function suffix str
  669. put the number of chars of str into n
  670. return char 3 to n of str
  671. end suffix
  672.  
  673.  
  674.  
  675. ----This is the script for the "Blank" background
  676. ----Insert these lines and uncomment them if the script ever gets
  677. ----trashed out
  678. --on openCard
  679. --get the short name of this card
  680. --if the first char of it is "B" then
  681. -- hide cd pict
  682. -- visual effect dissolve to black
  683. --go back
  684. --end if
  685. --end openCard
  686.  
  687.  
  688.  
  689.  
  690.  
  691.  
  692. on doEnter
  693.   --enters data on maps and in index
  694.   --not supported
  695.   global thename
  696.   answer "Is the data on the current map?" with "Yes" or "No"
  697.   if it is "No" then
  698.     set the result to -3
  699.     answer "Go to the correct map and try again" with "OK"
  700.     exit doEnter
  701.   end if
  702.   ask "What is the name of the datapoint?" with "nothing"
  703.   if it is "nothing" then
  704.     set the result to -3
  705.     exit doEnter
  706.   end if
  707.   put it into thename
  708.   put the userlevel into ul
  709.   set the userlevel to 5 --(authoring)
  710.   answer "Click near a clear place for the label" with "OK"
  711.   wait until the mouseclick
  712.   answer "Drag label to destination" with "OK"
  713.   choose text tool
  714.   set the textfont to Geneva
  715.   set the textsize to 9
  716.   put the textheight into th
  717.   click at the clickloc
  718.   type name
  719.   choose select tool
  720.   put item 1 of the clickloc into lft
  721.   put item 2 of the clickloc into tp
  722.   subtract th from tp
  723.   subtract 4 from lft
  724.   drag from  lft,tp to (lft + 6*nchar), (tp + th + 3)
  725.   doMenu "Transparent"
  726.   ---
  727. end doEnter
  728.  
  729. on doClick  --not done
  730.   global indx,indy,thename
  731.   answer "Is this a city location?" with "Yes" or "No"
  732.   --Cities get little black dots, others stuff don't
  733.   put it into ansr
  734.   answer "Please click on the exact location"
  735.   wait until the mouseclick
  736.   put item 1 of the clickloc into indx
  737.   put item 2 of the clickloc into indy
  738.   --insert it in the index, (steal code from home)
  739. end doClick
  740.  
  741. on popUL
  742.   global USRLVL
  743.   set the userlevel to USRLVL
  744. end popUL
  745.  
  746.  
  747. -------Colleen's custom utilities
  748. on doubleEncrypt bgfn,key   --bgfn is the name of a background field
  749.   set the locktext of bg fld bgfn to false
  750.   put bg fld bgfn into temp
  751.   put the number of chars of key into kl
  752.   put encrypt (temp,key,kl) into bg fld bgfn
  753.   set the locktext of bg fld bgfn to true
  754. end doubleEncrypt
  755.  
  756.  
  757. function encrypt str,key,kl
  758. put the number of chars of str into nc
  759. put 1 into k
  760. repeat with j = 1 to nc
  761.   set the cursor to busy
  762.   if k > kl then put 1 into k
  763.   put charToNum(char j of str) into n1
  764.   put charToNum(char k of key) into n2
  765.   if n1 <> n2 then put xor(n1,n2) into n2
  766.   put numtoChar(n2) into char j of str
  767.   add 1 to k
  768. end repeat
  769. return str
  770. end encrypt
  771.  
  772.  
  773.  
  774. function xor a,b
  775. put 0 into answer
  776. repeat with i = 0 to 7
  777.   if a >= 2^(7-i) then  --a is,
  778.     if not (b >= 2^(7-i)) then
  779.       add 2^(7-i) to answer
  780.     else
  781.       subtract 2^(7-i) from b
  782.     end if
  783.     subtract 2^(7-i) from a
  784.   else if b >= 2^(7-i) then --b is
  785.     if not (a >= 2^(7-i)) then
  786.       add 2^(7-i) to answer
  787.     else
  788.       subtract 2^(7-i) from a
  789.     end if
  790.     subtract 2^(7-i) from b
  791.   end if
  792. end repeat
  793. return answer
  794. end xor
  795.  
  796. function enterKey dummy
  797. put empty into key
  798. ask "How many key numbers?"
  799. if it is empty then exit enterKey
  800. put it into kn
  801. repeat with i = 1 to kn
  802.   ask "Carefully enter each key number, then press RETURN"
  803.   if it is empty then
  804.     return ""
  805.   end if
  806.   put numtoChar(it) after key
  807. end repeat
  808. return key
  809. end enterKey
  810.  
  811.  
  812. on doDeCrypt
  813.   ask "Enter 2-letter postal code for state to decrypt"
  814.   put "I-"&it into cdn
  815.   go cd cdn of stack "¬ßControl"
  816.   if the result is not empty then
  817.     answer "No such state--try again"
  818.     exit doDeCrypt
  819.   end if
  820.   put enterKey() into key
  821.   if key is empty then exit doDeCrypt
  822.   answer "Please enter key again to verify"
  823.   put enterKey() into vkey
  824.   if it is empty then exit doDeCrypt
  825.   if vkey <> key then
  826.     answer "Key mismatch--try again"
  827.     exit doDeCrypt
  828.   end if
  829.   put bg fld "‚Ä¢lyrics" into lcrypt
  830.   put bg fld "‚Ä¢song data" into scrypt
  831.   doubleEncrypt "‚Ä¢lyrics",key
  832.   doubleEncrypt "‚Ä¢song data",key
  833.   hide cd pict
  834.   show bg fld "‚Ä¢lyrics"
  835.   beep
  836.   answer "Verify:  Is deCryption OK?" with "Yes" or "No"
  837.   if it is "No" then
  838.     put lcrypt into bg fld "‚Ä¢lyrics"
  839.     put scrypt into bg fld "‚Ä¢song data"
  840.   else
  841.     put empty into bg fld "‚Ä¢encrypt"
  842.   end if
  843. end doDeCrypt
  844.  
  845. on doNewPW
  846.   global SQPW,TCPW  --the two passwords, respectively
  847.   answer "Which Password do you want to change?" with "Quiz Options" or "Score Card"
  848.   put it into tmp
  849.   ask "Old Password?"
  850.   if it is "Cancel" then exit doNewPW
  851.   else put it into OPW
  852.   ask "New Password?"
  853.   if it is "Cancel" then exit doNewPW
  854.   put it into NPW
  855.   if tmp is "Quiz Options" then
  856.     if SQPW = OPW then
  857.       put NPW into SQPW
  858.     else
  859.       beep
  860.       answer "Key mismatch--try again"
  861.     end if
  862.   else
  863.     if TCPW = OPW then
  864.       put NPW into TCPW
  865.     else
  866.       beep
  867.       answer "Key mismatch--try again"
  868.     end if
  869.   end if
  870. end doNewPW
  871.  
  872.  
  873. on cleanUSHome
  874.   lock screen
  875.   hide cd fld "State name"
  876.   repeat with i = 2 to 51
  877.     set the cursor to busy
  878.     set the showname of cd btn i to true
  879.   end repeat
  880.   unlock screen
  881. end cleanUSHome
  882.  
  883.  
  884.